<template>
  <div class="container">
    <el-dialog
      title="商品批次"
      :visible.sync="bactchDialogs.centerDialogVisible"
      @open="getData"
      width='60%'
      center
    >
      <el-table :data="tableData" border style="width: 100%" empty-text="暂无数据">
        <el-table-column prop="goods_name" label="商品名称" align="center"></el-table-column>
        <el-table-column prop="code" label="商品批次" align="center"></el-table-column>
        <el-table-column prop="purchase_price" label="价格" align="center"></el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
          @size-change="handleCurrentChange"
          @current-change="handleSizeChange"
          :current-page.sync="pageData.page"
          :page-sizes="pageData.pageSizes"
          :page-size="pageData.pageSize"
          :layout="pageData.layout"
          :total="pageData.total"
        ></el-pagination>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getGoodsDetails } from "@/api/supplier/supplierList";
export default {
  props: {
    bactchDialogs: Object
  },
  data() {
    return {
      tableData: [],
      options: [
        {
          value: "",
          label: "全部商品"
        },
        {
          value: 0,
          label: "未开税票商品"
        },
        {
          value: 1,
          label: "开过税票商品"
        }
      ],
      value: "",
      pageData: {
        pageSizes: [10, 20],
        pageSize: 10,
        page: 1,
        total: null,
        layout: "total, sizes, prev, pager, next, jumper"
      }
    };
  },
  methods: {
    confirm() {
      this.bactchDialogs.centerDialogVisible = false;
    },
    getData() {
      let data = {
        limit: this.pageData.pageSize,
        page: this.pageData.page,
        supplier_id: this.bactchDialogs.id
      };
      getGoodsDetails(data).then(res => {
        if (res.code == 0) {
          this.tableData = res.data.data;
          this.pageData.page = res.data.current_page;
            this.pageData.pagesize = res.data.per_page;
            this.pageData.total = res.data.total;
        }
      });
    },
    // 选择状态
    selectVal() {
      this.getData();
    },
    //每页多少条
    handleCurrentChange(val) {
      this.pageData.page = 1;
      this.pageData.pageSize = val;
      this.getData();
    },
    //选取页数
    handleSizeChange(page) {
      this.pageData.page = page;
      this.getData();
    }
  }
};
</script>
<style scoped>
.top {
  margin-bottom: 5px;
}
.pagination {
  text-align: right;
  padding: 10px;
}
</style>